<?php

/*

Process Battle 1-player (battle_1player.pro.php)

*/
ob_start();
$rank_check = 1;
include "global.inc.php";

$checkStatus = fetch("SELECT * FROM one_player_battles2 WHERE userid = '$userid' AND game = '$game'");
if ($checkStatus[id])
{
	die(header(error("battling_1p.php?game=$game","You are already in a fight!")));
}

$findEnemy = fetch("SELECT * FROM one_players2 WHERE guys_left > '0' AND id = '$id' AND game = '$game'");
if (!$findEnemy[id])
{
	die(header(error("battle_1player.php?game=$game","You cannot fight this enemy right now.")));
}

$findPet = fetch("SELECT * FROM user_pets2 WHERE owner = '$userid' AND id = '$usepet' AND current_hp > '0' AND hunger > '4' AND game = '$game'");
if (!$findPet[id])
{
	die(header(error("battle_1player.php?game=$game&id=$id&act=prestart","That pet is not able to be used right now. Please choose another.")));
}

mysql_query("INSERT INTO one_player_battles2 (userid,your_pet,enemy,enemy_hp,game) VALUES ('$userid','$findPet[id]','$findEnemy[id]','$findEnemy[health]','$game')");

die(header(error("battling_1p.php?game=$game","Your battle has been started!")));

?>